package com.jci.xyf.hellofx;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;

import java.io.IOException;
import java.net.URL;

public class MainController {
    @FXML
    private AnchorPane anch;
    @FXML
    public void opencinema() {
        anch.getChildren().clear();
        Parent root= null;
        try {
            root = FXMLLoader.load(new URL("file:src/main/resources/com/jci/xyf/hellofx/oil.fxml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        Button button=new Button("返回主界面");
        button.setOnAction(new EventHandler<>() {
            @Override
            public void handle(ActionEvent event) {
                Parent root1= null;
                try {
                    root1 = FXMLLoader.load(new URL("file:src/main/resources/com/jci/xyf/hellofx/mainscenne.fxml"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                anch.getChildren().clear();
                anch.getChildren().add(root1);
            }
        });
        anch.getChildren().add(root);
        anch.getChildren().add(button);
        button.prefWidth(40);
        button.setLayoutX(420);
    }
    @FXML
    public void opentaobao() {
        anch.getChildren().clear();
        Parent root= null;
        try {
            root = FXMLLoader.load(new URL("file:src/main/resources/com/jci/xyf/hellofx/tbselect.fxml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        Button button=new Button("返回主界面");
        button.setOnAction(new EventHandler<>() {
            @Override
            public void handle(ActionEvent event) {
                Parent root1= null;
                try {
                    root1 = FXMLLoader.load(new URL("file:src/main/resources/com/jci/xyf/hellofx/mainscenne.fxml"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                anch.getChildren().clear();
                anch.getChildren().add(root1);
            }
        });
        anch.getChildren().add(root);
        anch.getChildren().add(button);
        button.prefWidth(40);
        button.setLayoutX(420);
    }
    public void openqq() {
        anch.getChildren().clear();
        Parent root= null;
        try {
            root = FXMLLoader.load(new URL("file:src/main/resources/com/jci/xyf/hellofx/qq.fxml"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        Button button=new Button("返回主界面");
        button.setOnAction(new EventHandler<>() {
            @Override
            public void handle(ActionEvent event) {
                Parent root1= null;
                try {
                    root1 = FXMLLoader.load(new URL("file:src/main/resources/com/jci/xyf/hellofx/mainscenne.fxml"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                anch.getChildren().clear();
                anch.getChildren().add(root1);
            }
        });
        anch.getChildren().add(root);
        anch.getChildren().add(button);
        button.prefWidth(40);
        button.setLayoutX(420);
    }
}